<template>
	<view class="columnbox wdh-100 content">
		<view class="wdh-100 rowbox jus station-box">
			<image :src="img" mode="aspectFill" class="station-img"></image>
			<view class="columnbox als">
				<view class="s-name">{{name}}</view>
				<view class="s-address">{{address}}</view>
			</view>
		</view>
		<view class="rowbox wdh-100 jus top-box">
			工位信息
		</view>
		<view class="rowbox  spb one-info">
			<view>工位名称</view>
			<input v-model="doorName" placeholder="请输入" />
		</view>
		<view class="rowbox  spb one-info">
			<view>工位类型</view>
			<radio-group @change="doorTypeChange" v-model="doorType" style="white-space: nowrap;">
				<radio style="transform: scale(.7);" :checked="item.value==doorType"
					v-for="(item,index) in doorTypeList" :value="item.value">
					<text style="transform: scale(1.4);margin-left: 20rpx;margin-right: -20rpx;">{{item.title}}</text>
				</radio>
			</radio-group>
		</view>
		<!-- <view class="rowbox  spb one-info">
            <view>设备类型</view>
            <picker @change="businessHoursChange" :range="businessHoursList" range-key="name">
                <view class="rowbox">
                    {{businessHoursList[businessHours].name}}
                    <view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
                </view>
            </picker>
        </view> -->

		<view class="rowbox  spb one-info">
			<view>设备类型</view>
			<picker @change="deviceType=$event.detail.value" :range="deviceTypeOptions" range-key="name">
				<view class="rowbox">
					{{deviceTypeOptions[deviceType].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
			<!-- <input v-model="deviceType" placeholder="请输入" /> -->
		</view>

		<view class="rowbox  spb one-info">
			<view>模式</view>
			<picker @change="doorRunType=$event.detail.value" :range="doorRunTypeOptions" range-key="name">
				<view class="rowbox">
					{{doorRunTypeOptions[doorRunType].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
			<!-- <input v-model="deviceType" placeholder="请输入" /> -->
		</view>

		<view class="rowbox  spb one-info">
			<view>继电器SN</view>
			<input v-model="relaySn" placeholder="请输入" />
		</view>

		<view class="rowbox  spb one-info">
			<view>相机内SN</view>
			<input v-model="cameraOut" placeholder="请输入" />
		</view>
		<view class="rowbox  spb one-info">
			<view>相机外SN</view>
			<input v-model="cameraIn" placeholder="请输入" />
		</view>
		<view class="rowbox  spb one-info">
			<view>工位状态</view>
			<picker @change="opesTypeChange" :range="opesTypeList" range-key="name">
				<view class="rowbox">
					{{opesTypeList[opesType].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>
		<view class="rowbox wdh-100 jus top-box">
			命令控制
		</view>
		<view class="rowbox  spb one-info">
			<view>OUT1开</view>
			<picker @change="()=>{
                out10=$event.detail.value
            }" :range="outList" range-key="name">
				<view class="rowbox">
					{{outList[out10].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>
		<view class="rowbox  spb one-info">
			<view>OUT2开</view>
			<picker @change="()=>{
                out20=$event.detail.value
            }" :range="outList" range-key="name">
				<view class="rowbox">
					{{outList[out20].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>
		<view class="rowbox  spb one-info">
			<view>OUT3开</view>
			<picker @change="()=>{
                out30=$event.detail.value
            }" :range="outList" range-key="name">
				<view class="rowbox">
					{{outList[out30].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>
		<view class="rowbox  spb one-info">
			<view>OUT4开</view>
			<picker @change="()=>{
                out40=$event.detail.value
            }" :range="outList" range-key="name">
				<view class="rowbox">
					{{outList[out40].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>


		<view class="rowbox  spb one-info">
			<view>OUT1闭</view>
			<picker @change="()=>{
                out11=$event.detail.value
            }" :range="outListClose" range-key="name">
				<view class="rowbox">
					{{outListClose[out11].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>
		<view class="rowbox  spb one-info">
			<view>OUT2闭</view>
			<picker @change="()=>{
                out21=$event.detail.value
            }" :range="outListClose" range-key="name">
				<view class="rowbox">
					{{outListClose[out21].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>
		<view class="rowbox  spb one-info">
			<view>OUT3闭</view>
			<picker @change="()=>{
                out31=$event.detail.value
            }" :range="outListClose" range-key="name">
				<view class="rowbox">
					{{outListClose[out31].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>
		<view class="rowbox  spb one-info">
			<view>OUT4闭</view>
			<picker @change="()=>{
                out41=$event.detail.value
            }" :range="outListClose" range-key="name">
				<view class="rowbox">
					{{outListClose[out41].name}}
					<view style="margin-left: 20rpx;"> <u-icon name="arrow-down" size="24rpx"></u-icon></view>
				</view>
			</picker>
		</view>
		<view class="small-btn one-btn" @click="submitInfo">保存</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				doorName: '',
				doorType: '0',
				doorTypeList: [{
						title: '自动洗车',
						value: '0'
					},
					{
						title: '自助洗车',
						value: '1'
					},
					{
						title: '人工洗车',
						value: '2'
					}
				],
				cameraIn: '',
				cameraOut: '',
				opesTypeList: [{
						name: '空闲'
					},
					{
						name: '使用中'
					},
					{
						name: '维修中'
					}
				],
				opesType: 0,
				outList: [{
						name: '不启用'
					},
					{
						name: 'JY-开'
					},
					{
						name: 'JY-全开(外)'
					},
					{
						name: 'JY-全开(内)'
					},
					{
						name: 'JY-闪开'
					},
				],
				out10: 0,
				out20: 0,
				out30: 0,
				out40: 0,
				outListClose: [{
						name: '不启用'
					},
					{
						name: 'JY-闭'
					},
					{
						name: 'JY-全闭(外)'
					},
					{
						name: 'JY-全闭(内)'
					},
					{
						name: 'JY-闪闭'
					},
				],
				out11: 0,
				out21: 0,
				out31: 0,
				out41: 0,
				submitflag: false,
				id: '',
				img: '',
				name: '',
				address: '',
				deviceType: 0,
				deviceTypeOptions: [{
					value: 0,
					name: '臻识相机'
				}],
				relaySn: '',
				doorRunType: 0, //运行模式
				doorRunTypeOptions: [{
						value: 0,
						name: '手动'
					},
					{
						value: 1,
						name: '自动'
					}
				],
			};
		},
		onLoad(options) {
			if (options.id) {
				this.id = options.id
				this.img = options.img
				console.log('====', this.img)
				this.name = options.name
				this.address = options.address
			}
		},
		methods: {
			submitInfo() {
				if (!this.submitflag) {
					this.submitflag = true
					uni.showLoading({
						title: '正在保存'
					})
					this.$req.post('/xcx/manager/stationDoor', {
						cameraIn: this.cameraIn,
						cameraOut: this.cameraOut,
						doorName: this.doorName,
						doorType: this.doorType * 1,
						opesType: this.opesType * 1,
						out10: this.out10 * 1,
						out11: this.out11 * 1,
						out20: this.out20 * 1,
						out21: this.out21 * 1,
						out30: this.out30 * 1,
						out31: this.out31 * 1,
						out40: this.out40 * 1,
						stationId: this.id,
						deviceType: this.deviceType,
						relaySn: this.relaySn,
						doorRunType: this.doorRunType
					}).then(res => {
						uni.hideLoading()
						this.submitflag = false
						if (res.data.code == 200) {
							uni.showModal({
								title: '添加成功',
								content: '',
								success: () => {
									uni.navigateBack()
								}
							})
						} else {
							uni.showModal({
								title: res.data.msg,
								success: () => {}
							})
						}
					})
				}
			},
			doorTypeChange(e) {
				this.doorType = e.detail.value
			},
			opesTypeChange(e) {
				this.opesType = e.detail.value
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		font-family: PingFang SC;
	}

	.one-info {
		width: 710rpx;
		padding: 32rpx 20rpx;
		border-bottom: #eef0f7 solid 1px;
		font-size: 28rpx;

		input {
			text-align: right;
			font-size: 28rpx;
		}
	}

	.right-box {
		width: 500rpx;
	}

	.img-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
	}

	.add-img {
		width: 120rpx;
		height: 120rpx;
		border: #c9ccd4 solid 1px;
		border-radius: 10rpx;
		margin-right: 20rpx;
		position: relative;
		margin-bottom: 10rpx;

		image {
			width: 120rpx;
			height: 120rpx;
			border-radius: 10rpx;
		}

		.delet-box {
			position: absolute;
			right: 0;
			top: 0;
			background: rgba(#fff, .7);
			border-radius: 100rpx;
		}
	}

	.top-box {
		margin-top: 20rpx;
		padding: 20rpx 32rpx;
		font-size: 32rpx;
		border-top: #eef0f7 solid 20rpx;

		image {
			width: 40rpx;
			height: 40rpx;
			margin-right: 10rpx;
		}
	}

	.one-btn {
		width: 710rpx;
		height: 90rpx;
		border-radius: 20rpx;
		margin: 40rpx 0;
	}

	.station-box {
		padding: 20rpx 20rpx;

		.station-img {
			width: 200rpx;
			height: 150rpx;
			border-radius: 20rpx;
			margin-right: 20rpx;
		}

		.s-name {
			font-size: 32rpx;
			font-weight: bold;
		}

		.s-address {
			font-size: 28rpx;
			color: #7a7a7a;
			margin-top: 20rpx;
		}
	}
</style>